package edu.usx.server.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import edu.usx.server.pojo.Sites;
import edu.usx.server.pojo.vo.SitesVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author Usx
 * @since 2024-07-18
 */
@Repository
public interface SitesMapper extends BaseMapper<Sites> {
    @Select("SELECT link FROM sites WHERE create_user = #{id}")
    public List<String> getLinkByCreateUser(Integer create_user);

    //新增link
    @Insert("insert into sites (name,category_id,status,link,create_user,description,icon,update_user,create_time,update_time) values(#{name},#{category_id},#{status},#{link},#{create_user},#{description},#{icon},#{update_user},#{create_time},#{update_time})")
    //insert into sites (name,category_id,status,link,create_user) values('百度',104,3,'www.baidu.com',1);
    //这里name,category_id,status都不能为空
    public void addLinkByCreateUser(String name, Integer category_id, Integer status, String link, Integer create_user, String description, String icon, Integer update_user, LocalDateTime create_time, LocalDateTime update_time);

    /**
     * @description: 获取服务信息，封装成VO实体列表返回
     * @author: Elapse
     * @date: 2024/7/23
     * @return: List<SitesVO>
     **/
    List<SitesVO> selectSiteVOList();

    /**
     * @description: 获取服务信息，封装成VO实体返回
     * @author: Elapse
     * @date: 2024/7/23
     * @return: SitesVO
     **/
    SitesVO selectSiteVOById(Integer id);

//    @Select("select * from sites where category_id = 1")
    List <Sites> getCommonSites();

//    @Select("select * from sites where id=#{id}")
    Sites getSitesById(Long id);
}
